<?php
/* 
 * author: fabricio s costa
 * version: 1.0
 * site: http://fabriciojf.com
 */
//segurança
require_once('com/fabriciojf/security/Permission.class.php');
Permission::requireInRole(array('admin','usuario'));

require_once('smarty/SmartyInclude.php');
require_once('com/fabriciojf/include/Menu.class.php');

// instancia um objeto smarty padrão
$smarty = SmartyInclude::getSmarty();
$ticket = $_REQUEST['ticket'];
$historico = $_REQUEST['historico'];

$menusuperior =
'<div class="menusuperior">' .
'    <a href="do.php?action=Home" class="menuesquerdo">Home</a>&nbsp;>' .
'    <a href="do.php?action=PainelControle">Painel de Controle</a>&nbsp;>' .
'    <a href="do.php?action=TicketListar">Listar Tickets</a>&nbsp;>&nbsp;Dados do Chamado' .
'    <a href="do.php?action=Logout" class="menudireito">Logout</a>' .
'    <div class="clear"></div> ' .
'</div>';

foreach ($historico as $row){    
    $idHistorico[] = $row->getId();
    $mensagemHist[] = $row->getMensagem();
    $dataHoraHist[] = $row->getDataHora();
    $usuario[] = $row->getUsuario()->getNick();
}

$idTicket = $ticket->getId();
$telefone = $ticket->getTelefone();
$assunto = $ticket->getAssunto();
$mensagem = $ticket->getMensagem();
$dataHora = $ticket->getDataHora();
$statusTicket = $ticket->getStatus()->getStatus();
$usuarioTicket = $ticket->getUsuario()->getNick();

// carrega o template
/* menu */
$smarty->assign('menuon',  Menu::getMenuOn());
$smarty->assign('menupost', Menu::getMenuPost());
$smarty->assign('menupage', Menu::getMenuPages());
$smarty->assign('menuticket', Menu::getMenuTicket());
$smarty->assign('menupostinativos', Menu::getMenuPostInativos());
$smarty->assign('menusuperior', Menu::getMenuSuperior());

$smarty->assign('idTicket', $idTicket);
$smarty->assign('telefone', $telefone);
$smarty->assign('assunto', $assunto);
$smarty->assign('mensagem', $mensagem);
$smarty->assign('dataHora', $dataHora);
$smarty->assign('usuarioTicket', $usuarioTicket);
$smarty->assign('statusTicket', $statusTicket);

$smarty->assign('idHistorico', $idHistorico);
$smarty->assign('mensagemHist', $mensagemHist);
$smarty->assign('dataHoraHist', $dataHoraHist);
$smarty->assign('usuarioHist', $usuario);

$smarty->display('TicketAbrir.tpl');

?>
